package com.itheima.sc.web.sms;


import com.itheima.sc.pojo.sms.HomeBrand;
import com.itheima.sc.result.Result;
import com.itheima.sc.service.sms.SmsHomeBrandService;
import com.itheima.sc.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/home/brand")
public class SmsHomeBrandController {

    @Autowired
    private SmsHomeBrandService brandService;

    //添加首页品牌推荐
    @PostMapping("/create")
    public Result addBrand(@RequestBody List<HomeBrand> homeBrands){
        brandService.addBrand(homeBrands);
        return Result.success(null);
    }
    //批量删除广告
    @PostMapping("/delete")
    public Result deleteBrand(@RequestParam List<Long> ids){
        brandService.deleteBrands(ids);
        return Result.success(null);
    }

    //查询广告列表
    @GetMapping("/list")
    public Result selectBrandList(@RequestParam Map<String,String> param){
        PageResult pageResult=brandService.selectBrandList(param);
        return Result.success(pageResult);
    }
    //批量修改首页推荐品牌的状态
    @PostMapping("/update/recommendStatus")
    public Result updateBrandStatus(@RequestParam List<Long> ids,@RequestParam("recommendStatus") Integer status){
        brandService.updateBrandStatus(ids,status);
        return Result.success(null);
    }

    //修改推荐品牌排序
    @PostMapping("/update/sort/{id}")
    public Result updateBrandSort(@PathVariable Long id,Integer sort){
        brandService.updateBrandSort(id,sort);
        return Result.success(null);
    }



}
